home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-08-16 | 3.8 KB | 135 lines | [TEXT/CWIE] |
- // Copyright © 1995-96 Apple Computer, Inc. All rights reserved.
- // Release Version: $ ODF 1 $
-
- //=======================================================================
- #ifndef FRAME_H
- #include "Frame.h"
- #endif
-
- #ifndef PART_H
- #include "Part.h"
- #endif
-
- // ----- Framework Layer -----
- #ifndef FWUTIL_H
- #include "FWUtil.h" // FW_CFacetContext, FW_Beep()
- #endif
-
- #ifndef FWCONTXT_H
- #include "FWContxt.h" // FW_CViewContext
- #endif
-
- // ----- Graphic Includes -----
- #ifndef FWRECT_H
- #include <FWRect.h> // FW_CRect
- #endif
-
- #ifndef FWRECSHP_H
- #include "FWRecShp.h" // FW_CRectShape
- #endif
-
- #ifndef FWPICSHP_H
- #include "FWPicShp.h" // FW_PPicture, FW_CPictureShape
- #endif
-
- #ifndef FWRRCSHP_H
- #include "FWRRcShp.h" // FW_CRoundRectShape
- #endif
-
- #ifndef SOM_DevUniv_STalker_xh
- #include "STalker.xh" // for STalker
- #endif
-
- //========================================================================================
- #ifdef FW_BUILD_MAC
- #pragma segment Sample4
- #endif
-
- //========================================================================================
- FW_DEFINE_AUTO(CSample4Frame)
-
- const FW_Boolean kWaitUntilDone = TRUE; // don't return until talking is finished.
- //========================================================================================
- CSample4Frame::CSample4Frame(Environment* ev, ODFrame* odFrame,
- FW_CPresentation* presentation, CSample4Part* sample3Part)
- : FW_CFrame(ev, odFrame, presentation, sample3Part),
- fSOMTalker(NULL),
- fPictShape(NULL)
- {
- this->MyInitPicture(ev);
- #ifdef FW_BUILD_MAC // can we do text-to-speech on Windows?
- fSOMTalker = new DevUniv_STalker;
- fSOMTalker->SayString(ev, "I use ODF", !kWaitUntilDone); // say it!
- #endif
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- void
- CSample4Frame::MyInitPicture(Environment* ev)
- {
- FW_CSharedLibraryResourceFile resFile(ev); // PICT resource in shared library
- #ifdef FW_BUILD_MAC
- const short kPictID = 2000;
- FW_CPicture picture(resFile, kPictID);
- fFrameRect = this->GetBounds(ev); // Get new Frame Rect
- fPictShape = FW_NEW(FW_CPictureShape, (picture, fFrameRect));
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- CSample4Frame::~CSample4Frame()
- {
- FW_START_DESTRUCTOR
- delete fPictShape;
- #ifdef FW_BUILD_MAC
- delete fSOMTalker;
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- void
- CSample4Frame::Draw(Environment *ev, ODFacet* odFacet, ODShape* invalidShape) // Override
- {
- FW_CViewContext context(ev, this, odFacet, invalidShape);
- // erase invalid shape
- FW_CRect invalidRect;
- context.GetClipRect(invalidRect);
- FW_CRectShape::RenderRect(context, invalidRect, FW_kFill, FW_kWhiteEraseInk);
-
- // draw the picture
- fPictShape->Render(context);
-
- // draw a frame around it
- FW_CRoundRectShape::RenderRoundRect(context,
- fFrameRect,
- FW_CPoint(FW_IntToFixed(30), FW_IntToFixed(30)),
- FW_kFrame,
- FW_CInk(FW_kRGBBlue));
- }
-
- //----------------------------------------------------------------------------------------
- FW_Boolean
- CSample4Frame::DoMouseDown(Environment* ev, const FW_CMouseEvent& theMouseEvent)
- {
- FW_UNUSED(ev);
- FW_UNUSED(theMouseEvent);
- #ifdef FW_BUILD_MAC
- fSOMTalker->SayString(ev, "Oh Boy", !kWaitUntilDone); // say it!
- #endif
- return TRUE; // we handled event
- }
-
- //----------------------------------------------------------------------------------------
- void
- CSample4Frame::FrameShapeChanged(Environment* ev)
- {
- FW_CFrame::FrameShapeChanged(ev);
- fFrameRect = this->GetBounds(ev); // Get new frame rect
- // modify picture
- FW_CPicture picture = fPictShape->GetPicture();
- fPictShape->SetGeometry(picture, fFrameRect);
- // force redraw of whole frame
- this->Invalidate(ev, fFrameRect);
- }
-